#ifndef __KillCockroachs__Impediments__
#define __KillCockroachs__Impediments__

#include "cocos-ext.h"
#include "cocos2d.h"

USING_NS_CC;
USING_NS_CC_EXT;
using namespace cocos2d::gui;

class Impediments : public CCNode
{
public:

	void removeSelf(CCObject* sender);
	void fRunEffectsDisappear(CCObject* sender);
	/// 
	/// select object name
	/// 
	/// Chon doi tuong vat can tra ve ten anh
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	char* fSelectObjectName();

	/// 
	/// select object image
	/// 
	/// Chon doi tuong vat can tra ve ten anh
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	char* fSelectObjectImage();

	/// 
	/// select Json file
	/// 
	/// Chon khung anh dau tien
	/// 
	///
	/// @author : Quach Van Quyet
	/// time_create:
	/// time_end:
	///

	char* fSelectObjectJson();

	/// 
	/// select Plist file
	/// 
	/// Chon khung anh dau tien
	/// 
	///
	/// @author : Quach Van Quyet
	/// time_create:
	/// time_end:
	///

	char * fSelectObjectPlist();

	/// 
	/// select object number frame
	/// 
	/// Chon doi tuong vat can tra ve so luong frame
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	int fSelectObjectNumberFrame();

	/// 
	/// Khoi tao gia tri ban dau cho Impediments
	/// 
	/// random phan loai, gan gia tri = 0 cho mAppear va mBroken
	/// 
	///
	/// @author 
	/// time_create:
	/// time_end:
	///
	Impediments();

	/// 
	/// Khoi tao gia tri ban dau cho Impediments
	/// type: loai cua vat can
	/// 
	/// gan gia tri mType = type, = 0 cho mAppear va mBroken
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	Impediments(int type);

	/// 
	/// Khoi tao gia tri ban dau cho Impediments
	/// type: loai cua vat can
	/// point: toa do cua vat can
	/// 
	/// gan gia tri mType = type, = 0 cho mAppear va mBroken, Position = point
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	Impediments(CCPoint point, int type);

	/// 
	/// set position voi 1 toa do
	/// point: toa do cua vat can truyen vao
	/// 
	/// gan gia tri Position = point
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fSetPosition(CCPoint point);

	/// 
	/// set position voi 2 diem x, y
	/// x: toa do diem x
	/// y: toa do diem y
	/// 
	/// gan gia tri Position = (x, y)
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fSetPosition(float x, float y);

	/// 
	/// set appear
	/// appear: gia tri can gan cho mAppear
	/// 
	/// gan gia tri moi appear cho mAppear
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fSetAppear(int appear);

	/// 
	/// set broken
	/// broken: gia tri can gan cho mBroken
	/// 
	/// gan gia tri moi broken cho mBroken
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fSetBroken(int broken);

	void fSetTimeDisAppearBeforeAppear(int timeDisAppear);

	/// 
	/// get position
	/// 
	/// tra ve gia tri Position
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	CCPoint fGetPosition();

	/// 
	/// get mType
	/// 
	/// tra ve gia tri cua mType
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	int fGetType();

	/// 
	/// get appear
	/// 
	/// tra ve gia tri cua mAppear
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	int fGetAppear();

	/// 
	/// get broken
	/// 
	/// tra ve gia tri cua mBroken
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	int fGetBroken();

	int fGetTimeDisAppearBeforeAppear();

	/// 
	/// effects broken
	/// 
	/// hieu ung vo nat
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fEffectsBroken();
	/// 
	/// run effects broken
	/// 
	/// chay hieu ung vo nat
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fRunEffectsBroken();

	/// 
	/// effects appear
	/// time: thoi gian xuat hien
	/// number: so lan chop chop
	///
	/// chay hieu ung xuat hien cua vat can, return ve CCActionInterval
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	CCActionInterval* fEffectsAppear(int time, int number);
	/// 
	/// run effects appear
	/// time: thoi gian xuat hien
	/// number: so lan chop chop
	///
	/// hieu ung xuat hien cua vat can
	/// 
	///
	/// @author
	/// time_create:
	/// time_end:
	///
	void fRunEffectsAppear(int time, int number);

	/// 
	/// effects disappear
	/// time: thoi gian bien mat
	/// 
	/// hieu ung bien mat voi thoi gian qui dinh, return CCFadeOut
	/// 
	///
	/// @author
	/// time_create: 
	/// time_end:
	///
	CCFadeOut* fEffectsDisappear(int time);
	/// 
	/// run effects disappear
	/// time: thoi gian bien mat
	/// 
	/// chay hieu ung bien mat voi thoi gian qui dinh
	/// 
	///
	/// @author
	/// time_create: 
	/// time_end:
	///
	void fRunEffectsDisappear(int time);

	/// 
	/// init value for Attribute
	/// 
	/// param1: point- vi tri khoi tao
	/// param2: type - gia tri cho mType
	/// 
	/// khoi tao gia tri cho cac thuoc tinh
	/// 
	///
	/// @author phuoc td
	/// time_create: 13/6/2014
	/// time_end:
	///
	void initValueForAttribute(CCPoint point, int type);

	/// 
	/// effect vibrate
	/// 
	/// time: thoi gian rung man hinh sau khi la vo vat can
	/// 
	/// tra ve hieu ung rung khi lam nguoi choi la vo vat can, return ve CCActionInterval
	/// 
	///
	/// @author
	/// time_create
	/// time_end:
	///
	CCActionInterval* fEffectsVibrate(float time);

	/// 
	/// Run update
	/// 
	/// delta: khoan thoi gian cap nhat lai
	/// 
	/// khoi chay bien mat vat can va thay doi trang thai
	/// 
	///
	/// @author
	/// time_create
	/// time_end:
	///
	void fRunUpdate(float delta);

	/// 
	/// Run update appear
	/// 
	/// delta: khoan thoi gian cap nhat lai
	/// 
	/// khoi chay hien thi vat can va thay doi trang thai
	/// 
	///
	/// @author
	/// time_create
	/// time_end:
	///
	void fRunUpdateAppear(float delta);

	/// 
	/// is broken and disappear
	/// 
	/// kiem tra trang thai cua vat can
	/// 
	///
	/// @author
	/// time_create
	/// time_end:
	///
	int fIsBrokenAndDisAppear();


	CCArmature * getArmature();

	/// 
	/// auto size
	/// 
	/// chinh lai scaleY impediment cho phu hop kick thuoc man hinh 
	/// 
	///
	/// @author
	/// time_create
	/// time_end:
	///
	float fAutoSizeImpediment();

	float fSelectObjectScale();
private:
	
	void onAnimationEvent(CCArmature *pArmature, MovementEventType eventType, const char *animationID); // quan ly cac trang thai cua animation
	CCArmature *armature;
	CCArmatureAnimation* animation;
	int mType; //phan loai cho vat can
	int mAppear; //su xuat hien cua vat can
	int mBroken; //su vo nat cua vat can
	int mTimeAppear; //time dung de dem luc an vat can
	int mTimeBeforeAppear;// time truoc khi xuat hien
	int mTimeDisAppearBeforeAppear; //thoi gian an cua vat can truoc khi xuat hien

};

#endif //vat can